<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %>
<%@ include file="/WEB-INF/common/taglibs.jsp"%>

<script type="text/javascript">

$(document).ready(function(){
	$(".block_title > .block_show").parent().collapseBlock({collapsed:false});

	// textarea maxlength
	$('textarea.limited').maxlength({
        'feedback' : '.charsLeft', 
		'useInput' : true
    });

	// form	validate
	//$.validator.messages.required	= "";	 //	field message not show behind
	$("#form_save").validate({
		rules: {
			"entity.loginCode": {required: true, isEnNum: true, minlength: 4, maxlength: 30},
			"entity.name": {required: true, stringMinLength: 1, stringMaxLength: 20},
			"entity.email": {required: false, email: true, maxlength: 30},
			"entity.phone":	{required: false, isTelNo: true, maxlength: 30},
			"entity.address":	{required: false, stringMaxLength: 80},
			"entity.memo":	{required: false}
		},
		invalidHandler:	function(e,	validator) {
			var	errors = validator.numberOfInvalids();
			if (errors)	{
				var	message	= "请正确填写简单验证表单信息！";
				$("div.warning span").html(message);
				$("div.warning").show();
			} else {
				$("div.warning").hide();
			}
		},
		onkeyup: false,
		// if use ajax submit, please override this function
		// if use struts2 action submit, please remove this function
		submitHandler: function(form) {
			form.submit();
		}
	});

	$("#button_save").click(function(){
		$("#form_save").submit();
	});

	$("#button_cancel").click(function(){
		$("#form_cancel").submit();
	});
});

</script>

<div class="layout">
	<div class="block m-b">
		<div class="block_title">
			<s:if test="entity.id == null">
				<h3>用户信息新增</h3>
			</s:if>
			<s:else>
				<h3>用户信息修改</h3>
			</s:else>
			<p class="block_show"></p>
		</div>
		<div class="block_container">
			<s:form id="form_cancel" method="get" action="userManager-list" namespace="/user"></s:form>
			<s:form id="form_save" method="post" action="userManager-save" namespace="/user">
			<div class="warning" style="display:none;">
				<span></span>
			</div>
			<input type="hidden" name="entity.id" id="entity.id" value="<s:property value='entity.id'/>" />
			<input type="hidden" name="entity.versionNo" id="entity.versionNo" value="<s:property value='entity.versionNo'/>" />
			<table cellpadding="0" cellspacing="0" class="table_form">
				<tbody>
					<tr>
						<th><em>*</em>登录名：</th>
						<td	style="width:250px;">
							<s:if test="entity.id == null"><%--新增--%>
								<input name="entity.loginCode" id="entity.loginCode" class="width_c" value="<s:property value='entity.loginCode'/>" />
							</s:if>
							<s:else><%--修改--%>
								<input type="hidden" name="entity.loginCode" id="entity.loginCode" class="width_c" value="<s:property value='entity.loginCode'/>" />
								<label><s:property value='entity.loginCode'/></label>
							</s:else>
						</td>
						<th><em>*</em>姓名：</th>
						<td><input name="entity.name" id="entity.name" class="width_c" value="<s:property value='entity.name'/>" /></td>
					</tr>
					<tr>
						<th>email：</th>
						<td	style="width:250px;"><input	name="entity.email" id="entity.email" class="width_c" value="<s:property value='entity.email'/>" /></td>
						<th>电话：</th>
						<td><input name="entity.phone" id="entity.phone" class="width_c" value="<s:property value='entity.phone'/>" /></td>
					</tr>
					<tr>
						<th>地址：</th>
						<td	colspan="3">
							<input name="entity.address" id="entity.address" style="width: 400px;" value="<s:property value='entity.address'/>" />
						</td>
					</tr>
					<tr>
						<th>备注：</th>
						<td	colspan="3">
							<textarea class="textarea limited" name="entity.memo" id="entity.memo" cols="100" rows="3"><s:property value='entity.memo'/></textarea>
							<p class="form_tips">可以输入<span class="charsLeft"></span>个字符</p>
							<%-- disabled input will not submit--%>
							<input type="hidden" name="maxlength" value="500" disabled="disabled" />
						</td>
					</tr>
				</tbody>
			</table>
			<div class="btn_center">
				<a id="button_save" class="easyui-linkbutton l-btn m-r" href="javascript:void(0)"><span class="l-btn-left"><span class="l-btn-text icon-save">保	存</span></span></a>
				<a id="button_cancel" class="easyui-linkbutton l-btn m-l" href="javascript:void(0)"><span class="l-btn-left"><span class="l-btn-text icon-undo">返	回</span></span></a>
			</div>
			</s:form>
		</div>
	</div>
</div>